
let data = [
  {name: '先进制造业', value: [{name: '产业1', value: 20}, {name: '产业2', value: 20}, {name: '产业3', value: 20}]},
  {name: '二大业', value: [{name: '产业5', value: 10}, {name: '产业6', value: 10}, {name: '产业7', value: 10}]},
  {name: '都市现代业', value: [{name: '产业9', value: 10}, {name: '产业10', value: 10}, {name: '产业11', value: 10}]}
];

let parents = data.map(d => ({name: d.name, value: d.value.reduce((a, b) => (a + b.value), 0)}));
let colorP = ['#f0f', '#00f', '#0ff'];

// 子类颜色使用父类颜色，在配置项修改透明度
let children = data.reduce((a, b, i) => a.concat(b.value.map(e => {
  e['itemStyle'] = {color: colorP[i]}; return e;})), []);

export let option = {
  tooltip: {
    trigger: 'item',
    formatter: '{a} <br/>{b}: {c} ({d}%)'
  },
  color: colorP,
  legend: {
    orient: 'vertical',
    x: 'left',
    data: parents.map(d => d.name)
  },
  series: [
    {
      name: '访问来源',
      type: 'pie',
      selectedMode: 'single',
      radius: ['15%', '38%'],
      label: {
        normal: {
          position: 'inner'
        }
      },
      labelLine: {
        normal: {
          show: false
        }
      },
      data: parents
    },
    {
      name: '访问来源',
      type: 'pie',
      radius: ['40%', '55%'],
      data: children,
      itemStyle: {opacity: 0.7, borderWidth: 1, borderColor: '#fff'}
    }
  ]
};

export const name = 'pieTwo';
